package com.xywy.bloodandroid.act;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.reflect.TypeToken;
import com.xywy.bloodandroid.R;
import com.xywy.bloodandroid.adapter.ArticleListAdapter;
import com.xywy.bloodandroid.base.BaseActivity;
import com.xywy.bloodandroid.bean.Article;
import com.xywy.bloodandroid.util.JsonUtil;

/*******************************************
 * @Title: ArticeListActivity.java
 * @Package com.xywy.bloodandroid.act
 * @Description: TODO文章列表
 * @author Benwolf
 * @date 2014-12-26 下午6:15:40
 * @version V1.0
 ********************************************/
public class ArticeListActivity extends BaseActivity {

	private RelativeLayout back;
	private TextView title;
	private TextView tv_content;
	private ListView lv_article_list;
	private List<Article> list = new ArrayList<Article>();
	private ArticleListAdapter adapter;

	@Override
	protected void initView(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		setContentView(R.layout.activty_article_list);
		back = (RelativeLayout) findViewById(R.id.left_img);
		title = (TextView) findViewById(R.id.middle_title);
		title.setText(getResources().getString(R.string.bp_news_str));
		lv_article_list = (ListView) findViewById(R.id.lv_article_list);

		String data = getIntent().getStringExtra("data");
		String dir = getIntent().getStringExtra("dirStr");
		String typeid = getIntent().getStringExtra("typeid");
		// getIntent().getSerializableExtra("data");
		list = (List<Article>) JsonUtil.parseJsonToList(data,
				new TypeToken<List<Article>>() {
				}.getType());
		adapter = new ArticleListAdapter(list, dir,typeid, this);
		lv_article_list.setAdapter(adapter);

	}

	@Override
	protected void initListener() {
		// TODO Auto-generated method stub
		back.setOnClickListener(this);
	}

	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		super.onClick(view);
		switch (view.getId()) {
		case R.id.left_img:
			finish();
			break;

		default:
			break;
		}
	}

	@Override
	protected void initData() {
	}

}
